package com.cqjtu.education.controller;

import com.cqjtu.education.entity.InboxRecipent;
import com.cqjtu.education.service.InboxRecipentService;
import com.github.pagehelper.Page;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (InboxRecipent)表控制层
 *
 * @author makejava
 * @since 2022-04-20 15:48:54
 */
@RestController
@RequestMapping("inboxRecipent")
public class InboxRecipentController {
    /**
     * 服务对象
     */
    @Resource
    private InboxRecipentService inboxRecipentService;


    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public ResponseEntity<InboxRecipent> queryById(@PathVariable("id") String id) {
        return ResponseEntity.ok(this.inboxRecipentService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param inboxRecipent 实体
     * @return 新增结果
     */
    @PostMapping
    public ResponseEntity<InboxRecipent> add(InboxRecipent inboxRecipent) {
        return ResponseEntity.ok(this.inboxRecipentService.insert(inboxRecipent));
    }

    /**
     * 编辑数据
     *
     * @param inboxRecipent 实体
     * @return 编辑结果
     */
    @PutMapping
    public ResponseEntity<InboxRecipent> edit(InboxRecipent inboxRecipent) {
        return ResponseEntity.ok(this.inboxRecipentService.update(inboxRecipent));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(String id) {
        return ResponseEntity.ok(this.inboxRecipentService.deleteById(id));
    }

}

